<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>MyHomework</title>
    <link rel="stylesheet" href="didadidala/css/common.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h1>Hello World!</h1>
<h2 style="color: #ff0000"></h2>
<br/>
<h2>使用表单提交</h2>
<form action="student/useModelAndView" method="post">
    <label>中文名字:
        <input name="name" type="text">
    </label>
    <br>
    <label>英文名字:
        <input name="englishName" type="text">
    </label>
    <br>
    <label>手机号码:
        <input name="phoneNumber" type="text">
    </label>
    <label>家庭住址:
        <input name="address" type="text">
    </label>
    <br>

    <label>出生日期:
        <input name="birthday" type="date">
    </label>
    <input type="submit"  value="提交">
</form>

<br>
<script>
    function requestHeader() {

        $.ajax(
            {
                url: "student/requestHead",
                type: "post",
                headers: {
                    eye: 'black eyes',
                    hair: "black hair"
                },
                success: function (res) {
                    console.log(res)
                }

            }
        )
    }

    function requestBody() {
        let stu = {};
        stu.name = "XXX";
        stu.address = "河南郑州";
        stu.phoneNumber = "16835684629";
        stu.englishName = "AAA";
        $.ajax(
            {
                url: "student/requestBody",
                type: "post",
                contentType: "application/json",
                data: JSON.stringify(stu),
                success: function (res) {
                    console.log(res.name)
                    alert(res.name)
                }
            }
        )
    }
    function requestBody01() {
        let stu = {};
        stu.name = "XXX";
        stu.address = "河南郑州";
        stu.phoneNumber = "16835684629";
        stu.englishName = "AAA";
        stu.xxx = "16835684629";
        $.ajax(
            {
                url: "student/requestBody01",
                type: "post",
                data: stu,
                success: function (res) {
                    console.log(res)
                }

            }
        )
    }
    function useResponse() {
        let stu = {};
        stu.name = "XXXuseResponse";
        stu.address = "河南郑州";
        stu.phoneNumber = "16835684629";
        $.ajax(
            {
                url: "student/useResponse",
                type: "post",
                data: JSON.stringify(stu),
                contentType: "application/json",
                dataType:"json",
                success: function (res) {
                    console.log(res)
                }

            }
        )
    }
    function useOurType() {
        let data = {};
        data.name = "XXX";
        data.address = "河南郑州";
        data.phoneNumber = "18039670878";
        $.ajax(
            {
                url: "student/useOurType",
                type: "post",
                data: data,
                success: function (res) {
                    console.log(res)
                }

            }
        )
    }
</script>
</body>
</html>